<%@ page import="com.informet.ipd.modelo.dao.MarcoLogicoDao" %>
<%@ page import="com.informet.ipd.modelo.vo.MarcoLogicoVO" %>
<%@ page import="com.informet.ipd.modelo.vo.FisiMetaMVO" %>
<%@ page import="com.informet.ipd.struts.form.ProgEstrForm" %>
<%@ page import="java.util.*" %>
<%@ page import="javax.swing.JOptionPane"%>
<%@ page language="java"  pageEncoding="UTF-8" contentType="text/html;charset=utf-8" %>
<%@ taglib uri="/tags/c" prefix="c"%>

<%
            StringBuffer cadenaSalida = new StringBuffer();
            List listac = null;
            List listaf = null;
            List listap = null;

            
            Double canfin = Double.parseDouble(request.getParameter("canfin"));
            Double canprop = Double.parseDouble(request.getParameter("canprop"));
            Double cancomp = Double.parseDouble(request.getParameter("cancomp"));
            
            MarcoLogicoDao supportFacade = new MarcoLogicoDao();
            ProgEstrForm form1 = new ProgEstrForm();
            MarcoLogicoVO oFMe = null;
            MarcoLogicoVO oFMe2 = null;
            MarcoLogicoVO oFMe3 = null;
            try {
                //int codMA = Integer.parseInt(request.getParameter("codMA"));
                //int codFM = Integer.parseInt(request.getParameter("codFM"));
                int tipo = Integer.parseInt(request.getParameter("tipo"));
                int pk = Integer.parseInt(request.getParameter("pk"));
                int pk2 = Integer.parseInt(request.getParameter("pk2"));
                int opc=Integer.parseInt(request.getParameter("opc"));
                if(opc==1){
                    oFMe = new MarcoLogicoVO(pk2, pk, canfin,"","");
                    supportFacade.spManf(tipo, oFMe);
                }
                if(opc==2){
                    oFMe = new MarcoLogicoVO(pk2, pk, canprop,"");
                    supportFacade.spManp(tipo, oFMe);
                }
                if(opc==3){
                    oFMe = new MarcoLogicoVO(pk2, pk, cancomp);
                    supportFacade.spMan(tipo, oFMe);
                }

                




                



                listac = supportFacade.getlistMarcoLogicoComponente();
                listaf = supportFacade.getlistMarcoLogicoFin();
                listap = supportFacade.getlistMarcoLogicoProposito();
                form1.setListDetalleMarcoLogicoComponente(listac);
                form1.setListDetalleMarcoLogicoProposito(listap);
                form1.setListDetalleMarcoLogicoFin(listaf);

                cadenaSalida.append("<table id='tabla1' width='99%' align='right' class='userTable'>");
                cadenaSalida.append("<tr class='even' align='center'>");

               

                cadenaSalida.append("<th class='textoTR' rowspan='2'>Jerarquia de Objetivos</th>");
                cadenaSalida.append("<th class='textoTR' colspan='3'>Meta Planificada</th> ");

                cadenaSalida.append("<th class='textoTR'>Avance de Meta</th> ");
                cadenaSalida.append("<th class='textoTR' rowspan='2'>Fuente de Informacion</th> ");
                cadenaSalida.append("<th class='textoTR' rowspan='2'>Editar</th> ");
                cadenaSalida.append("</tr>");
                cadenaSalida.append("<th class='textoTR'>Cantidad</th> ");
                cadenaSalida.append("<th class='textoTR'>Detalle</th> ");
                cadenaSalida.append("<th class='textoTR'>Tipo</th> ");
                cadenaSalida.append("<th class='textoTR'>Cantidad</th> ");
                cadenaSalida.append("</tr>");
                cadenaSalida.append("<th class='textoTR' colspan='7'>Fin</th> ");
                cadenaSalida.append("</tr>");
                int i=1;
                Iterator it = listaf.iterator();
                Iterator it2=listap.iterator();
                Iterator it3 = listac.iterator();
                
                while (it.hasNext()) {
                    oFMe = (MarcoLogicoVO) it.next();
                    //oFMe2 = (MarcoLogicoVO) it2.next();
                    cadenaSalida.append("<tr align='center'> ");
                    cadenaSalida.append("<td width='10%' align='center'>" + oFMe.getTX_DESCFINPRG() + "</td>");
                    cadenaSalida.append("<td width='10%' align='center'>" + oFMe.getNUM_CANTMETAFINPRG() + "</td>");
                    cadenaSalida.append("<td width='10%' align='center'>" + oFMe.getTX_DESCMETAFINPRG() + "</td>");





                     if (oFMe.getTX_TIPOMETAFINPRG() == 1) {
                            cadenaSalida.append("<td width='10%' align='center'>" + "N" + "</td>");
                        }
                        if (oFMe.getTX_TIPOMETAFINPRG() == 2) {
                            cadenaSalida.append("<td width='10%' align='center'>" + "%" + "</td>");
                        }

                    cadenaSalida.append("<td width='10%' align='center'>" + oFMe.getNUM_CANTMETAFINPRGC() + "</td>");
                    cadenaSalida.append("<td width='10%' align='center'>" + oFMe.getTX_FUEMETAFINPPRG() + "</td>");
                    cadenaSalida.append("<td width='10%' align='center'>");
                    cadenaSalida.append("<img style='cursor:pointer' title='Editar' alt='Editar' border=0  src='images/b_edit.png' onclick=\"editarF('"+oFMe.getNUM_FINPRG_PK()+"','"+oFMe.getNUM_METAFINPRG_PK()+"','"+oFMe.getNUM_CANTMETAFINPRGC()+"','"+1+"');\">");
                    cadenaSalida.append("</td>");
                    cadenaSalida.append("</tr>");

                    }

                cadenaSalida.append("<tr>");
                cadenaSalida.append("<th class='textoTR' colspan='7'>Proposito</th> ");
                cadenaSalida.append("</tr>");



                while (it2.hasNext()) {
                    oFMe2 = (MarcoLogicoVO) it2.next();
                    //oFMe2 = (MarcoLogicoVO) it2.next();
                    cadenaSalida.append("<tr align='center'> ");
                    cadenaSalida.append("<td width='10%' align='center'>" + oFMe2.getTX_DESCPROPPRG() + "</td>");
                    cadenaSalida.append("<td width='10%' align='center'>" + oFMe2.getNUM_CANTMETAPROPPRG() + "</td>");
                    cadenaSalida.append("<td width='10%' align='center'>" + oFMe2.getTX_DESCMETAPROPPRG() + "</td>");



                     if (oFMe2.getTX_TIPOMETAPROPPRG() == 1) {
                            cadenaSalida.append("<td width='10%' align='center'>" + "N" + "</td>");
                        }
                        if (oFMe2.getTX_TIPOMETAPROPPRG() == 2) {
                            cadenaSalida.append("<td width='10%' align='center'>" + "%" + "</td>");
                        }

                    cadenaSalida.append("<td width='10%' align='center'>" + oFMe2.getNUM_CANTMETAPROPPRGC() + "</td>");
                    cadenaSalida.append("<td width='10%' align='center'>" + oFMe2.getTX_FUENTEPROPPRG() + "</td>");
                    cadenaSalida.append("<td width='10%' align='center'>");
                    cadenaSalida.append("<img style='cursor:pointer' title='Editar' alt='Editar' border=0  src='images/b_edit.png' onclick=\"editarP('"+oFMe2.getNUM_PROPPRG_PK()+"','"+oFMe2.getNUM_METAPROPPRG_PK()+"','"+oFMe2.getNUM_CANTMETAPROPPRGC()+"','"+2+"');\">");
                    cadenaSalida.append("</td>");
                    cadenaSalida.append("</tr>");
                    }
                
                cadenaSalida.append("<tr>");
                cadenaSalida.append("<th class='textoTR' colspan='7'>Componente</th> ");
                cadenaSalida.append("</tr>");



                while (it3.hasNext()) {
                    oFMe3 = (MarcoLogicoVO) it3.next();
                    cadenaSalida.append("<tr align='center'> ");
                    cadenaSalida.append("<td width='10%' align='center'>" + oFMe3.getTX_DESCCOMPPRG() + "</td>");
                    cadenaSalida.append("<td width='10%' align='center'>" + oFMe3.getNUM_CANTMETACOMPPRG() + "</td>");
                    cadenaSalida.append("<td width='10%' align='center'>" + oFMe3.getTX_DESCMETACOMPPRG() + "</td>");



                     if (oFMe3.getTX_TIPOMETACOMPPRG() == 1) {
                            cadenaSalida.append("<td width='10%' align='center'>" + "N" + "</td>");
                        }
                        if (oFMe3.getTX_TIPOMETACOMPPRG() == 2) {
                            cadenaSalida.append("<td width='10%' align='center'>" + "%" + "</td>");
                        }

                    cadenaSalida.append("<td width='10%' align='center'>" + oFMe3.getNUM_CANTMETACOMPPRGC() + "</td>");
                    cadenaSalida.append("<td width='10%' align='center'>" + oFMe3.getTX_FUENTECOMPPRG() + "</td>");
                    cadenaSalida.append("<td width='10%' align='center'>");
                    cadenaSalida.append("<img style='cursor:pointer' title='Editar' alt='Editar' border=0  src='images/b_edit.png' onclick=\"editarC('"+oFMe3.getNUM_COMPPRG_PK()+"','"+oFMe3.getNUM_METACOMPPRG_PK()+"','"+oFMe3.getNUM_CANTMETACOMPPRGC()+"','"+3+"');\">");
                    cadenaSalida.append("</td>");
                    cadenaSalida.append("</tr>");
                    }


                

                

                
                //JOptionPane.showMessageDialog(null,"chau lisatrmetafisicaajax");
            } catch (Exception e) {
                 cadenaSalida.append("error : "+e.toString());
            }
            out.print(cadenaSalida);
%>